import { http } from './http'
import { PageQueryParams, PageResponse } from '@/config/page'

export interface DocLinkQueryParams extends PageQueryParams {
  docId?: number;
}

export interface DocLinkCreateParams {
  docId: number;

  accessCode?: string;

  expiredTime?: string;

  remark?: string;

  allowPreview?: boolean;

  allowDownload?: boolean;

  allowUpload?: boolean;

  allowEdit?: boolean;
}

export interface DocLinkUpdateParams {
  accessCode?: string;

  expiredTime?: string;

  remark?: string;

  allowPreview?: boolean;

  allowDownload?: boolean;

  allowUpload?: boolean;

  allowEdit?: boolean;
}

/**
 * 创建文档链接。
 * @param params
 * @returns
 */
export function createDocLink (params: DocLinkCreateParams) {
  return http().post<any>('/api/document/doc-links', params)
}

/**
 * 更新文档链接。
 * @param params
 * @returns
 */
export function updateDocLink (id: number, params: DocLinkUpdateParams) {
  return http().put<any>(`/api/document/doc-links/${id}`, params)
}

/**
 * 删除文档链接。
 * @param params
 * @returns
 */
export function deleteDocLink (id: number) {
  return http().delete<any>(`/api/document/doc-links/${id}`)
}

// /**
//  * 批量删除。
//  * @param ids
//  * @returns
//  */
// export function deteteInbatch (ids: number[]) {
//   return http().delete<any>('/api/document/messages/delete', { ids })
// }

/**
 * 分页查询用户外链。
 * @param params
 * @returns
 */
export function queryDocLinks (params: PageQueryParams) {
  return http().get<PageResponse<any>>('/api/document/doc-links', { params })
}
